using System;

namespace WebAndLoadTestPluginsAndRules.Common
{
    public class ExactMatchFilter : Filter
    {
        public string Filter { get; set; }
        public bool IgnoreCase { get; set; }

        public ExactMatchFilter(string filter, bool ignoreCase)
        {
            if (string.IsNullOrEmpty(filter))
            {
                throw new ArgumentException("filter must be specified", "filter");
            }
            Filter = filter;
            IgnoreCase = ignoreCase;
        }

        public override bool Matches(string value)
        {
            if (value == null)
            {
                return false;
            }
            return value.Equals(Filter, IgnoreCase ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture);
        }
    }
}